package ar.com.spsolutions.splilabrary.view.pages.book.comment;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.request.cycle.RequestCycle;

import ar.com.spsolutions.splibrary.book.Book;
import ar.com.spsolutions.splilabrary.view.application.WebSession;
import ar.com.spsolutions.splilabrary.view.pages.book.loan.LoanEditComponent;

public class SaveComment extends WebPage {
    private static final long serialVersionUID = 4158952281137429372L;

    public SaveComment() {
        super();
        Book book;
        String commentText = RequestCycle.get().getRequest().getPostParameters().getParameterValue("name").toString();
        // BookComment comment = new BookComment(((WebSession)
        // getSession()).getUser(), commentText);
        book = LoanEditComponent.getBook();
        book.addComment(((WebSession) getSession()).getUser(), commentText);
        LoanEditComponent.getLibraryServiceFacadeLEC().update(book);
    }

}
